﻿<%@ page contentType="text/html;charset=UTF8" import="java.sql.*" %>
<% request.setCharacterEncoding("UTF8"); %>
<%
	Connection conn = null;
	Statement stmt = null;

	String jdbc_driver = "org.gjt.mm.mysql.Driver";
	String jdbc_url = "jdbc:mysql://localhost:3306/test";

	try{
		Class.forName(jdbc_driver);
		conn = DriverManager.getConnection(jdbc_url,"root","root");
		stmt = conn.createStatement();
	} catch(Exception e) {
		System.out.println(e);
	}

%>
<HTML>
	<BODY>
	<%
		try{
			String sql = "select * from testtable where id > 1 and id < 7";
			ResultSet rs = stmt.executeQuery(sql);
			int i=1;
			
			while(rs.next()) {
				out.println(i+" : "+rs.getString(1)+" , "+rs.getString(2)+" , "+rs.getString(3)+"<BR>");
				i++;
			}
			
			rs.close();
			stmt.close();
			conn.close();
		} catch(Exception e) {
			System.out.println(e);
		}
	%>
	</BODY>
</HTML>